<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="projects.milestone" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="milestone" class="projects.milestone"></jsp:useBean>
<jsp:setProperty property="*" name="milestone"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../General Info/css.css" />
<title>Insert title here</title>
</head>

<%
if (request.getParameter("id") == null){
	response.sendRedirect("../General Info/dashboard.jsp");
	}
else if (session.getAttribute("loggedIn") == null) {
	response.sendRedirect("../User/index.jsp");
	}
else{
	milestone mil = new milestone();
	mil.setMilestoneId(Integer.parseInt(request.getParameter("id")));
	Integer projectId = mil.queryProjectId();
%>

<body>

<jsp:include page="../General Info/header.jsp"/>

<%/* <!-- -----------------------------------------------> Submeniu <-------------------------------------------------- --> */%>
	<div class="submenu">
		<ul class="submenuBar">
			<%
			String projectLink = "../Projects/projectDashboard.jsp?id="+ projectId;
			String milestoneLink = "../Milestones/milestone.jsp?id="+ mil.getMilestoneId();
			%>
			<li><a href=<% out.println(projectLink); %> class="submenuButton">Project</a></li>
			<li><a href=<% out.println(milestoneLink); %> class="submenuButton">Work Packages</a></li>
		</ul>
	</div>
	
<% /* ------------------------------------------------------------------------------------------------------------------------------- */ %>
		<div class="body">
		<div class="upb">
			<div class="projects">
			<div class="projectsHeader">Create a New Task</div>
			</br>
			<form name="addNewTaskForm" onsubmit="" method="GET" action="../Tasks/addTask.jsp">
			<input type="hidden" name="hMilestoneId" id="hMilestoneId" value=<%out.println(mil.getMilestoneId()); %> /> 
				<table>
					<tr>
						<td>Task Name:</td>
						<td><input id="taskName" class="" type="text" onblur="" name="taskName" /></td>
					</tr>
					<tr>
						<td>Task Description:</td>
						<td><input id="taskDesc" class="" type="text" onblur="" name="taskDesc" /></td>
					</tr>
					<tr>
						<td>Start date:</td>
						<td><input id="startDate" class="" type="text" onblur="" name="startDate" /></td>
					</tr>
					<tr>
						<td>End date:</td>
						<td><input id="endDate" class="" type="text" onblur="" name="endDate" /></td>
					</tr>
					<tr>
						<td>Task Type:</td>
						<td><select name="taskType" id="taskType">
							<option value="1">BUG</option>
							<option value="2">TASK</option>
							<option value="3">IMPROVEMENT</option>
							<option value="4">NEW FEATURE</option>
							<option value="6">REQUIREMENT</option>
							<option value="7">IMPEDIMENT</option>
							</select></td>
					</tr>
					<tr>
						<td>Task Priority:</td>
						<td><select name="taskPriority" id="taskPriority">
							<option value="1">BLOCKER</option>
							<option value="2">CRITICAL</option>
							<option value="3">MAJOR</option>
							<option value="4">MINOR</option>
							<option value="5">TRIVIAL</option>
							</select></td>
					</tr>
					<tr>
						<td>Task Effort:</td>
						<td><input id="taskEffort" class="" type="text" onblur="" name="taskEffort" /></td>
					</tr>
					<tr>
						<td>Task status:</td>
						<td><select name="taskStatus">
							<option value="1">NEW</option>
							<option value="2">ASIGNED</option>
							<option value="3">RESOLVED</option>
							<option value="4">CLOSED</option>
							<option value="5">REOPENED</option>
							</select></td>
					</tr>
					<tr>
						<td>Task resolution:</td>
						<td><select name="taskResolution">
							<option value="5">NEW</option>
							<option value="1">FIXED</option>
							<option value="2">WOUN'T FIX</option>
							<option value="3">DUPLICATE</option>
							<option value="4">INVALID</option>
							</select></td>
					</tr>
					<tr>
						<td></td>
						<td><input type="submit" class="inputButton" value="Create Task" /></td>
					</tr>
				</table>
				<%
					if(session.getAttribute("postback")=="true")
					{
						if (session.getAttribute("createTask")=="true") { %>
							<div class="successfulChange" id="successfulChange">Status and resolution changed successfully!!</div>
							<%session.setAttribute("createTask", null);
							session.setAttribute("postback", null);
						}
						else if(session.getAttribute("createTask")=="false") {
							%><div class="notsuccessfulChange" id="notsuccessfulChange">Could not change status and resolution!!!</div>
							<%session.setAttribute("createTask", null);
							session.setAttribute("postback", null);
						}
					}
					else{
						%><div class="noChange" id="noChange"></div>	
					<%}%>
			</form>
</div>
</div>
<div class="push"></div>
</div>
<jsp:include page="../General Info/footer.jsp"/>
</body>
<%} %>
</html>